<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var fruit = prompt();
        switch (fruit) {
            case 'apple':
                alert(111);
                break;
            case 1:
                alert(222);
                break;
            default:
                alert('no');
                break;
        }
    </script>
</head>

<body>
    <!-- switch选择的变量值和case值必须全等 值和类型都相同才可 -->
</body>

</html>